//
//  Data+Ext.swift
//  KLExtension
//
//  Created by nkl on 2023/6/29.
//

import Foundation

extension Data {
    public func toJSON() -> AnyObject? {
        do {
            return try JSONSerialization.jsonObject(with: self, options: .mutableContainers) as AnyObject
        } catch {
            print(error)
        }
        return nil
    }

    public func toString() -> String? {
        let jsonString = String(data: self, encoding: .utf8)
        return jsonString
    }
}
